package hr.sting.droidorm.util;

import hr.sting.beans.PropertyInfo;
import hr.sting.droidorm.OrmEntityDescriptor;

/**
 * @author mstipanov
 * @since 20.07.2010. 21:24:56
 */
public class PropertyReplacer {
    public <T> String replaceProperties(String s, OrmEntityDescriptor<T> descriptor) {
        if (null == s) {
            return null;
        }

        for (String col : descriptor.getColumnNames()) {
            PropertyInfo property = descriptor.getProperty(col);
            s = s.replaceAll("\\b" + col + "\\b", property.getName());
        }

        return s;
    }
}
